<?
require_once('class/restrictpage.php');
canConnectFor("ADMIN");
require_once('../Connections/conn.php');
require_once('class/DeliveryType.class.php');
if(!empty($_GET['up']))
{
		$up=base64_decode($_GET['up']);
		$sql="SELECT  *  	FROM  sme_delivery_type   WHERE  delivery_Id =$up";
		$recordSql = mysql_query ( $sql,$conn );
		$row = mysql_num_rows($recordSql);
	if($row != 0)
		$obj = mysql_fetch_array($recordSql);
		else {echo  "<meta http-equiv='refresh' content='0;URL=delivery.php'>";exit();}
}
else {echo  "<meta http-equiv='refresh' content='0;URL=delivery.php'>";exit();}
	
if(!empty($_POST['submit']))
{
	$form=new delivery_type();
       
	
		$form->set($_POST['delivery_name'],$_POST['box_weight'],$_POST['service_charge'],$_POST['com'],$_POST['sh']);
	if($form->update($up)){
	echo  "<meta http-equiv='refresh' content='0;URL=delivery.php'>";}
}


?>

<!doctype html>
<html lang="th"><!-- InstanceBegin template="/Templates/temp.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<? 
$setac= array();
for($i=0;$i<9;$i++)
$setac[$i]="";
?>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet"  href="backstore_css.css" />
<!-- InstanceBeginEditable name="doctitle" -->

<title>หลังร้าน>> แก้ไขการขนส่ง </title>
<? $setac[4]="class=\"active\""; ?>
<!-- InstanceEndEditable -->
<link rel="icon" type="image/x-icon" id="favicon" href="img/faviconc.ico"/>
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
#contain #main #content table {
	color: #963;
	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
	font-size: 14px;
	text-align: left;
}

.warning {
	color: #F00;
}
</style>
<script language="JavaScript" type="text/javascript">
function trim( text ){
    return text.replace(/^\s*/, "").replace(/\s*$/, "");
}
function chkform ( form )
{
	var i=0;
  var  alpha=/^[ก-๙a-zA-Z0-9\s]+$/;
  var num=/^[0-9]+$/;
   if(trim(document.getElementById("delivery_name").value)=="")
  {document.getElementById("dn").innerHTML="<img src=\"img/nav-logout.gif\"/>กรุณากรอกชื่อการขนส่ง"; 
  i++;
   }
  else if(!alpha.test(document.getElementById("delivery_name").value))
   {document.getElementById("dn").innerHTML="<img src=\"img/nav-logout.gif\"/>ห้ามกรอกสัญลักษณ์"; 
  i++;
   }
  
  else document.getElementById("dn").innerHTML="";
 
   if(trim(document.getElementById("box_weight").value)=="")
  { document.getElementById("bw").innerHTML="<img src=\"img/nav-logout.gif\"/>กรุณากรอกน้ำหนักเฉลี่ย";   
  i++;
   }
 else if(!num.test(document.getElementById("box_weight").value))
  {document.getElementById("bw").innerHTML="<img src=\"img/nav-logout.gif\"/>กรุณากรอกเป็นตัวเลข"; 
  i++;
  }
  else document.getElementById("bw").innerHTML="";
  
	if(trim(document.getElementById("service_charge").value)=="")
  {	  document.getElementById("sc").innerHTML="<img src=\"img/nav-logout.gif\"/>กรุณากรอกค่าบริการเสริม"; 
  i++;
   }
  else if(!num.test(document.getElementById("service_charge").value))
  {document.getElementById("sc").innerHTML="<img src=\"img/nav-logout.gif\"/>กรุณากรอกเป็นตัวเลข";
  i++; }
  else document.getElementById("sc").innerHTML="";
 if(i==0)
 return true;
 else
 return false;
 
}
//-->
</script>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="contain">
<?php require("inc/menu_admin.php") ?>
<div id="main">
<ul id="submenu">
  <!-- InstanceBeginEditable name="EditRegion2" -->
<li><a href="delivery_form.php"><img src="img/add.gif" alt="" style="width: 16px; height: 16px;" />เพิ่มการขนส่งใหม่</a></li>
  <!-- InstanceEndEditable -->			
</ul>
<div id="content">
<div class="path_bar">
<!-- InstanceBeginEditable name="EditRegion6" -->
<img src="img/prefs.gif" style="margin-right: 10px;" /><a href="#">หลังร้าน</a> &gt;&gt; 
<img src="img/AdminShipping.gif" style="margin-right: 5px;" /><a href="delivery.php">การขนส่ง</a>&gt;&gt; 
<img src="img/edit.gif" style="margin-right: 10px;" />แก้ไขการขนส่ง <? echo $obj[1]; ?> 
<!-- InstanceEndEditable -->
</div>
<!-- InstanceBeginEditable name="EditRegion1" -->
<form method="post" name="form1" id="form1"  onsubmit="return chkform(this);"  >
   <p id="unique"   class="warning"><? echo  $unique; ?></p>
  <table width="500" height="193"  >
    <tr bgcolor="#F0F0F0">
      <th width="159" align="right">ชื่อการขนส่ง </th>
      <td width="375"><input name="delivery_name"  type="text" id="delivery_name" value="<? echo $obj[1]; ?>" size="40" />
         <p id="dn" class="warning"></p>
       
         </td>
         
    </tr>
    <tr bgcolor="#FBFBFB">
      <th align="right">น้ำหนักเฉลี่ยของกล่อง<br />
        ที่ใช้ในการขนส่ง</th>
      <td>
        <input name="box_weight" type="text" id="box_weight" value="<? echo $obj[2]; ?>" size="10" /> 
        กรัม
        <p id="bw"   class="warning"></p>
        </td>
    </tr>
    <tr bgcolor="#F0F0F0">
      <th align="right" >ค่าบริการเสริมต่อกล่อง</th>
      <td>
        <input name="service_charge" type="text" id="service_charge" value="<? echo $obj[3]; ?>" size="10" /> 
        บาท
        <p id="sc" class="warning"></p>
        </td>
    </tr>
    <tr >
      <th align="right">หมายเหตุการขนส่ง</th>
      <td><textarea name="com" id="com" cols="45" rows="5"><? echo $obj[4]; ?></textarea></td>
    </tr>
    <tr bgcolor="#F0F0F0" >
      <th align="right">การแสดงตัวเลือก<br />
การขนส่งสินค้าใน<br />
หน้าการขาย</th>
      <td><input name="sh" type="radio" id="radio" value="1" checked="checked" />
        <img src="img/enabled.gif" width="16" height="16" />
<input type="radio" name="sh" id="radio2" value="0" />
<img src="img/delete.gif" width="16" height="16" /></td>
    </tr>
    <tr >
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr bgcolor="#F0F0F0">
      <td colspan="2"  align="center">
      <input type="submit" name="submit" id="submit" value="บันทึก" />   &nbsp;      
      <input type="reset" name="reset" id="reset" value="ยกเลิก"  />
      </td>
      </tr>
  </table>
</form>
<br style="clear: both;"/>
<br style="clear: both;"/>
<!-- InstanceEndEditable -->
</div>
</div>
</div>
<?php require("inc/footer_admin.php") ?>
</body>
<!-- InstanceEnd --></html>